home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / string / nsString.h < prev    next >
C/C++ Source or Header  |  2006-05-08  |  7KB  |  238 lines

  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* vim:set ts=2 sw=2 sts=2 et cindent: */
  3. /* ***** BEGIN LICENSE BLOCK *****
  4.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  5.  *
  6.  * The contents of this file are subject to the Mozilla Public License Version
  7.  * 1.1 (the "License"); you may not use this file except in compliance with
  8.  * the License. You may obtain a copy of the License at
  9.  * http://www.mozilla.org/MPL/
  10.  *
  11.  * Software distributed under the License is distributed on an "AS IS" basis,
  12.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  13.  * for the specific language governing rights and limitations under the
  14.  * License.
  15.  *
  16.  * The Original Code is Mozilla.
  17.  *
  18.  * The Initial Developer of the Original Code is IBM Corporation.
  19.  * Portions created by IBM Corporation are Copyright (C) 2003
  20.  * IBM Corporation. All Rights Reserved.
  21.  *
  22.  * Contributor(s):
  23.  *   Darin Fisher <darin@meer.net>
  24.  *
  25.  * Alternatively, the contents of this file may be used under the terms of
  26.  * either the GNU General Public License Version 2 or later (the "GPL"), or
  27.  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28.  * in which case the provisions of the GPL or the LGPL are applicable instead
  29.  * of those above. If you wish to allow use of your version of this file only
  30.  * under the terms of either the GPL or the LGPL, and not to allow others to
  31.  * use your version of this file under the terms of the MPL, indicate your
  32.  * decision by deleting the provisions above and replace them with the notice
  33.  * and other provisions required by the GPL or the LGPL. If you do not delete
  34.  * the provisions above, a recipient may use your version of this file under
  35.  * the terms of any one of the MPL, the GPL or the LGPL.
  36.  *
  37.  * ***** END LICENSE BLOCK ***** */
  38.  
  39. #ifndef nsString_h___
  40. #define nsString_h___
  41.  
  42.  
  43. #ifndef nsSubstring_h___
  44. #include "nsSubstring.h"
  45. #endif
  46.  
  47. #ifndef nsDependentSubstring_h___
  48. #include "nsDependentSubstring.h"
  49. #endif
  50.  
  51. #ifndef nsReadableUtils_h___
  52. #include "nsReadableUtils.h"
  53. #endif
  54.  
  55. #include NEW_H
  56.  
  57.   // enable support for the obsolete string API if not explicitly disabled
  58. #ifndef MOZ_STRING_WITH_OBSOLETE_API
  59. #define MOZ_STRING_WITH_OBSOLETE_API 1
  60. #endif
  61.  
  62. #if MOZ_STRING_WITH_OBSOLETE_API
  63.   // radix values for ToInteger/AppendInt
  64. #define kRadix10        (10)
  65. #define kRadix16        (16)
  66. #define kAutoDetect     (100)
  67. #define kRadixUnknown   (kAutoDetect+1)
  68. #define IGNORE_CASE     (PR_TRUE)
  69. #endif
  70.  
  71.  
  72.   // declare nsString, et. al.
  73. #include "string-template-def-unichar.h"
  74. #include "nsTString.h"
  75. #include "string-template-undef.h"
  76.  
  77.   // declare nsCString, et. al.
  78. #include "string-template-def-char.h"
  79. #include "nsTString.h"
  80. #include "string-template-undef.h"
  81.  
  82.  
  83.   /**
  84.    * A helper class that converts a UTF-16 string to ASCII in a lossy manner
  85.    */
  86. class NS_LossyConvertUTF16toASCII : public nsCAutoString
  87.   {
  88.     public:
  89.       explicit
  90.       NS_LossyConvertUTF16toASCII( const PRUnichar* aString )
  91.         {
  92.           LossyAppendUTF16toASCII(aString, *this);
  93.         }
  94.  
  95.       NS_LossyConvertUTF16toASCII( const PRUnichar* aString, PRUint32 aLength )
  96.         {
  97.           LossyAppendUTF16toASCII(Substring(aString, aString + aLength), *this);
  98.         }
  99.  
  100.       explicit
  101.       NS_LossyConvertUTF16toASCII( const nsAString& aString )
  102.         {
  103.           LossyAppendUTF16toASCII(aString, *this);
  104.         }
  105.  
  106.     private:
  107.         // NOT TO BE IMPLEMENTED
  108.       NS_LossyConvertUTF16toASCII( char );
  109.   };
  110.  
  111.  
  112. class NS_ConvertASCIItoUTF16 : public nsAutoString
  113.   {
  114.     public:
  115.       explicit
  116.       NS_ConvertASCIItoUTF16( const char* aCString )
  117.         {
  118.           AppendASCIItoUTF16(aCString, *this);
  119.         }
  120.  
  121.       NS_ConvertASCIItoUTF16( const char* aCString, PRUint32 aLength )
  122.         {
  123.           AppendASCIItoUTF16(Substring(aCString, aCString + aLength), *this);
  124.         }
  125.  
  126.       explicit
  127.       NS_ConvertASCIItoUTF16( const nsACString& aCString )
  128.         {
  129.           AppendASCIItoUTF16(aCString, *this);
  130.         }
  131.  
  132.     private:
  133.         // NOT TO BE IMPLEMENTED
  134.       NS_ConvertASCIItoUTF16( PRUnichar );
  135.   };
  136.  
  137.  
  138.   /**
  139.    * A helper class that converts a UTF-16 string to UTF-8
  140.    */
  141. class NS_ConvertUTF16toUTF8 : public nsCAutoString
  142.   {
  143.     public:
  144.       explicit
  145.       NS_ConvertUTF16toUTF8( const PRUnichar* aString )
  146.         {
  147.           AppendUTF16toUTF8(aString, *this);
  148.         }
  149.  
  150.       NS_ConvertUTF16toUTF8( const PRUnichar* aString, PRUint32 aLength )
  151.         {
  152.           AppendUTF16toUTF8(Substring(aString, aString + aLength), *this);
  153.         }
  154.  
  155.       explicit
  156.       NS_ConvertUTF16toUTF8( const nsAString& aString )
  157.         {
  158.           AppendUTF16toUTF8(aString, *this);
  159.         }
  160.  
  161.     private:
  162.         // NOT TO BE IMPLEMENTED
  163.       NS_ConvertUTF16toUTF8( char );
  164.   };
  165.  
  166.  
  167. class NS_ConvertUTF8toUTF16 : public nsAutoString
  168.   {
  169.     public:
  170.       explicit
  171.       NS_ConvertUTF8toUTF16( const char* aCString )
  172.         {
  173.           AppendUTF8toUTF16(aCString, *this);
  174.         }
  175.  
  176.       NS_ConvertUTF8toUTF16( const char* aCString, PRUint32 aLength )
  177.         {
  178.           AppendUTF8toUTF16(Substring(aCString, aCString + aLength), *this);
  179.         }
  180.  
  181.       explicit
  182.       NS_ConvertUTF8toUTF16( const nsACString& aCString )
  183.         {
  184.           AppendUTF8toUTF16(aCString, *this);
  185.         }
  186.  
  187.     private:
  188.         // NOT TO BE IMPLEMENTED
  189.       NS_ConvertUTF8toUTF16( PRUnichar );
  190.   };
  191.  
  192.  
  193. // the following are included/declared for backwards compatibility
  194.  
  195. typedef NS_ConvertUTF16toUTF8 NS_ConvertUCS2toUTF8;
  196. typedef NS_LossyConvertUTF16toASCII NS_LossyConvertUCS2toASCII;
  197. typedef NS_ConvertASCIItoUTF16 NS_ConvertASCIItoUCS2;
  198. typedef NS_ConvertUTF8toUTF16 NS_ConvertUTF8toUCS2;
  199. typedef nsAutoString nsVoidableString;
  200.  
  201. #ifndef nsDependentString_h___
  202. #include "nsDependentString.h"
  203. #endif
  204.  
  205. #ifndef nsLiteralString_h___
  206. #include "nsLiteralString.h"
  207. #endif
  208.  
  209. #ifndef nsPromiseFlatString_h___
  210. #include "nsPromiseFlatString.h"
  211. #endif
  212.  
  213. // need to include these for backwards compatibility
  214. #include "nsMemory.h"
  215. #include <string.h>
  216. #include <stdio.h>
  217. #include "plhash.h"
  218.  
  219. inline PRInt32 MinInt(PRInt32 x, PRInt32 y)
  220.   {
  221.     return NS_MIN(x, y);
  222.   }
  223.  
  224. inline PRInt32 MaxInt(PRInt32 x, PRInt32 y)
  225.   {
  226.     return NS_MAX(x, y);
  227.   }
  228.  
  229. /**
  230.  * Deprecated: don't use |Recycle|, just call |nsMemory::Free| directly
  231.  *
  232.  * Return the given buffer to the heap manager. Calls allocator::Free()
  233.  */
  234. inline void Recycle( char* aBuffer) { nsMemory::Free(aBuffer); }
  235. inline void Recycle( PRUnichar* aBuffer) { nsMemory::Free(aBuffer); }
  236.  
  237. #endif // !defined(nsString_h___)
  238.